package
{
  import com.dougmccune.containers.CoverFlowContainer;
  
  import mx.collections.ArrayCollection;
  import mx.events.CollectionEvent;
  
  public class VideoCoverFlow extends CoverFlowContainer
  {
    private var _dataProvider:ArrayCollection;
    
    public function VideoCoverFlow()
    {
      this.setStyle("horizontalGap", 40);
      this.reflectionEnabled = true;
    }
    
    public function set dataProvider(_dataProvider:ArrayCollection):void
    {
      this._dataProvider = _dataProvider;
      this._dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, updateItems);
      updateItems();
    }
    
    public function get dataProvider():ArrayCollection
    {
      return _dataProvider;
    }
    
    // this could be more efficient
    private function updateItems(event:CollectionEvent=null):void
    {
      this.removeAllChildren();
      
      for each (var i:Object in dataProvider)
      {
        this.addChild(new MyVideo(i.thumbnail, i.flv));
      }
    }
  }
}